#!/bin/bash


CURRENTDIR=`pwd`
cd `dirname $0`


function usage {
	echo -e "\033[0;34m\033[1m"
	echo -e "          - ProCycle manual maintenance utility -\033[0m"
	echo -e " Purpose is to efficiently track the manual changes through"
	echo -e " Mercurial which better handles text files than binary files."
	echo -e ""
	echo -e "Usage:"
	echo -e "  ./manual.sh [-i --inflate] [-d --deflate]"
	echo -e "     -i --inflate   inflate the doc to directory (odt -> hg)"
	echo -e "     -d --deflate   deflate the directory to doc (hg -> odt)"
	echo -e ""
	echo -e "  One (and only one) of the options must be specified"
	echo -e ""
}


if [ $# -ne 1 ]
then
	usage
	exit 1
fi


MANUAL_FILE=procycle-manual.odt
MANUAL_DIR=manual


if [[ ($1 == -i) || ($1 == --inflate) ]]
then
	unzip -o $MANUAL_FILE -d $MANUAL_DIR
elif [[ ($1 == -d) || ($1 == --deflate) ]]
then
	cd $MANUAL_DIR && zip -r ../$MANUAL_FILE -xi *
else
	usage
fi


cd $CURRENTDIR



